package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.Dict;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 字典表 Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-07-26
 */
public interface DictMapper extends BaseMapper<Dict> {

    @Select("select IFNULL(max(num),0) as max_num from dict where type = #{type}")
    public abstract Integer getMaxNumForType(Integer type);

    @Select("select id as workerId,num as id,name,other_name,remark,status,type,count,money from dict ${ew.customSqlSegment}")
    public abstract IPage<Dict> findAll(IPage<?> page, @Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select id as workerId,num as id,name,other_name,remark,status,type from dict ${ew.customSqlSegment}")
    public abstract List<Map<String,Object>> getList( @Param(Constants.WRAPPER) Wrapper wrapper);
}
